#!/usr/bin/perl -w
use strict;
use LWP;
use Includes;

# Start the browser
my $browser = LWP::UserAgent->new;

open(OUTFILE,">/tmp/output.txt");
print OUTFILE "Checking email";
my $hash = Includes::get_hash();
# Loop through each line
while(<>){
	# If it contains a url
	if(/<[aA] (?:href|HREF)=(['"])(.*)\1/){
		my $url = $2;
		printf OUTFILE "URL found: %s\n",$url;
		# Fetch the URL
		my $response = $browser->get(
				join("&",$url,sprintf("hash=%s",$hash))
				);
		print OUTFILE $response->content;
	}
}
print OUTFILE "Done checking\n";
